function c = gfisequal(a, b, p)
  [lhs rhs] = argn();
  if rhs < 3
    p = 2;
  end
  if p < 2 | p ~= int(p)
    error('p must be an prime number');
  end
  if max(a) > p-1 | max(b) > p-1 | min(a) < 0 | min(b) < 0
    error('elements of a and b must integers in the range [0, p-1]')
  end
  if a ~= int(a)
    error('elements of a and b must integers in the range [0, p-1]')
  end
  if b ~= int(b)
    error('elements of a and b must integers in the range [0, p-1]')
  end
  if size(a, 1) ~= 1 | size(b,1) ~= 1
    error('a and b must be row vectors');
  end

  len1 = size(a, 2);
  len2 = size(b, 2);
  if len1 > len2
    //a is longer than b
    b = [b zeros(1, len1-len2)];
  else
    //b is longer or equal a
    a = [a zeros(1, len2-len1)];
  end
  c = and(a == b)
endfunction
